/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package imageexample;




/**
 *
 * @author rodrigo
 */
import java.io.IOException;
import javax.imageio.ImageIO;
import java.io.File;
import java.awt.image.BufferedImage;
import java.awt.*;
import javax.swing.*;
import java.awt.Graphics;
 
 
public class NewImage extends Panel{
 
    int w, h;
    BufferedImage cat;
    
    public static void main(String[] args) throws IOException
    {
        BufferedImage img = ImageIO.read(new File("C:/Users/rodrigo/Desktop/ETC/mine´s/DSC01005.jpg"));
        NewImage im = new NewImage(img);
        JFrame frame = new JFrame("Display image");
        Panel panel = im;
        frame.getContentPane().add(panel);
        frame.setSize(500, 500);
        frame.setVisible(true);
    }
    
	public NewImage(BufferedImage img) throws java.io.IOException {
		cat = img;
                w=cat.getWidth();
                h=cat.getHeight();
	}
        
     @Override
      public Dimension getPreferredSize() {
         return new Dimension(w, h);
     }
     
    @Override
       public void paint(Graphics g){
	g = cat.getGraphics();
        g.drawImage(cat, 0, 0, null);
    }
}
 